package com.ht.medicaltreatment.adapter

import android.view.View
import android.widget.ImageView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.Group
import com.blankj.utilcode.util.LogUtils
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.bean.LocationBean

class LcoationFragmentAdatper : BaseQuickAdapter<LocationBean,BaseViewHolder>(R.layout.item_locaiton_layout){
    override fun convert(holder: BaseViewHolder, item: LocationBean) {
        holder.setText(R.id.tvName,item.name)
        holder.setText(R.id.tvCount,"${item.assetNum}")
        val group = holder.getView<Group>(R.id.group)
        var time = item.lastCheckDate
        if(time == null){
            time = ""
        }else if (time.length > 0){
            var timeArr = time.split(" ")
            if(timeArr.size > 0){
                time = timeArr[0]
            }
        }
        holder.setText(R.id.tvTime,time)
        val img = holder.getView<ImageView>(R.id.imgIcon)
        if(item.iconPath == ""){
            group.visibility = View.GONE
            Glide.with(context)
                .load(R.drawable.bg_search)
                .into(img)
        }else{
            Glide.with(context)
                .load(item.iconPath)
                .into(img)
        }
    }

}
